package com.itheima.tlias84.service.impl;

import com.itheima.tlias84.entity.Dept;
import com.itheima.tlias84.mapper.DeptMapper;
import com.itheima.tlias84.service.TestInsertDeptServiceOne;
import com.itheima.tlias84.service.TestInsertDeptServiceTwo;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.time.LocalDateTime;

@Service
public class TestInsertDeptServiceOneImpl implements TestInsertDeptServiceOne {
    @Resource
    DeptMapper deptMapper;

    @Resource
    TestInsertDeptServiceTwo two;
    @Transactional(rollbackFor = Exception.class)
    @Override
    public int insertDeptOne() {
        Dept dept = new Dept();
        dept.setName("测试传播one");
        dept.setCreateTime(LocalDateTime.now());
        dept.setUpdateTime(LocalDateTime.now());
        deptMapper.insertDept(dept);
        two.insertDeptTwo();
        return 0;
    }
}
